import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  // {
  //   path: '/login',
  //   component: () => import('@/views/login/index'),
  //   hidden: true
  // },

  // {
  //   path: '/404',
  //   component: () => import('@/views/404'),
  //   hidden: true
  // },

  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/lb',
  //   children: [{
  //     path: '/lb',
  //     name: 'Dashboard',
  //     component: () => import('@/views/lb/shequ'),
  //     meta: { title: '联邦社区设置', icon: 'dashboard' }
  //   }]
  // },
  {
    path: '/',
    component: Layout,
    redirect: '/sccn',
    meta: { title: '医疗模型部署', icon: 'el-icon-s-help' },
    children: [
      {
      path: '/sccn',
      name: 'Dashboard',
      children: [
        {
          path: '/sccn',
          name: 'sccn',
          component: () => import('@/views/ylmodel/sccn'),
          meta: { title: '生成承诺' }
        },
        {
          path: '/sccn/sctz',
          name: 'sctz',
          component: () => import('@/views/ylmodel/sctz'),
          meta: { title: '生成挑战' }
        },
        {
          path: '/sccn/yztz',
          name: 'sccn',
          component: () => import('@/views/ylmodel/yzcn'),
          meta: { title: '验证承诺' }
        }
      ],
      meta: { title: '模型验证' }
    },{
      path: '/download',
      name: 'Dashboard',
      component: () => import('@/views/ylmodel/mxxz'),
      meta: { title: '模型下载' }
    },
    {
      path: '/jiemi',
      name: 'Dashboard',
      component: () => import('@/views/ylmodel/mxjm'),
      meta: { title: '模型解密' }
    },
    {
      path: '/mxxl',
      name: 'Dashboard',
      component: () => import('@/views/ylmodel/mxxl'),
      meta: { title: '模型训练' }
    },
    {
      path: '/mxjm',
      name: 'Dashboard',
      component: () => import('@/views/ylmodel/mxjm'),
      meta: { title: '模型加密' }
    },
    {
      path: '/shangchuan',
      name: 'Dashboard',
      component: () => import('@/views/ylmodel/mxsc'),
      meta: { title: '模型上传' }
    },
    {
      path: '/sjqq',
      name: 'DataRequestCenter', // 唯一的名称
      redirect: 'sjjq', // 指向具体的子路径
      meta: { title: '模型验证' },
      children: [
        {
          path: 'sjjq', // 相对路径
          name: 'DataRequest', // 唯一的名称
          component: () => import('@/views/ylmodel/sjqq'),
          meta: { title: '数据请求' }
        },
        {
          path: 'sfrz', // 相对路径
          name: 'IdentityVerification', // 唯一的名称
          component: () => import('@/views/ylmodel/sfrz'),
          meta: { title: '身份认证' }
        },
        {
          path: 'sjcs', // 相对路径
          name: 'DataTransfer', // 唯一的名称
          component: () => import('@/views/ylmodel/sjcs'),
          meta: { title: '数据传输' }
        }
      ]
    }
    ]
  },
  // 隔断
  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/institution',
  //   children: [{
  //     path: '/institution',
  //     name: 'Dashboard',
  //     component: () => import('@/views/institution/index'),
  //     meta: { title: '系统概况', icon: 'dashboard' }
  //   }]
  // },
  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/manage',
  //   children: [{
  //     path: '/v',
  //     name: 'Dashboard',
  //     component: () => import('@/views/institution/manage'),
  //     meta: { title: '联邦社区管理', icon: 'dashboard' }
  //   }]
  // },
  {
    path: '/',
    component: Layout,
    redirect: '/allowInstition',
    meta: { title: '鉴权机构', icon: 'el-icon-s-help' },
    children: [{
      path: '/allowInstition',
      name: 'Dashboard',
      component: () => import('@/views/allowInstition/index'),
      meta: { title: '属性验证', icon: 'dashboard' }
    },{
      path: '/history',
      name: 'Dashboard',
      component: () => import('@/views/allowInstition/history'),
      meta: { title: '访问记录', icon: 'dashboard' }
    }]
  },
  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/kbHistrory',
  //   name: '个人中心',
  //   meta: { title: '个人中心', icon: 'el-icon-s-help' },
  //   children: [{
  //     path: '/kbHistrory',
  //     name: 'Dashboard',
  //     component: () => import('@/views/user/kbhistory'),
  //     meta: { title: '病例记录', icon: 'dashboard' }
  //   }, {
  //     path: '/fwkz',
  //     name: 'Dashboard',
  //     component: () => import('@/views/user/fwkz'),
  //     meta: { title: '访问控制', icon: 'dashboard' }
  //   }, {
  //     path: '/setrule',
  //     name: 'Dashboard',
  //     component: () => import('@/views/user/setrule'),
  //     meta: { title: '定制访问策略', icon: 'dashboard' }
  //   }]
  // },
  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/modelManage',
  //   name: '训练模型管理',
  //   meta: { title: '训练模型管理', icon: 'el-icon-s-help' },
  //   children: [
  //     {
  //       path: 'modelManage',
  //       name: 'modelManage',
  //       component: () => import('@/views/institution/modelManage'),
  //       meta: { title: '肺炎图像识别', icon: 'table' }
  //     },
  //     {
  //       path: 'bodyManage',
  //       name: 'bodyManage',
  //       component: () => import('@/views/institution/bodyManage'),
  //       meta: { title: '胸部图像识别', icon: 'table' }
  //     },
  //     {
  //       path: 'modelExport',
  //       name: 'modelExport',
  //       component: () => import('@/views/institution/modelExport'),
  //       meta: { title: '全局模型导出', icon: 'table' }
  //     }
  //     // {
  //     //   path: 'tree',
  //     //   name: 'Tree',
  //     //   component: () => import('@/views/tree/index'),
  //     //   meta: { title: '血液图像识别', icon: 'tree' }
  //     // }
  //   ]
  // },

  // {
  //   path: '/',
  //   component: Layout,
  //   redirect: '/createERO',
  //   name: '档案管理',
  //   meta: { title: '医生板块', icon: 'el-icon-s-help' },
  //   children: [
  //     {
  //       path: 'createEro',
  //       name: 'createEro',
  //       component: () => import('@/views/doctor/createERO'),
  //       meta: { title: '信息管理', icon: 'table' }
  //     },
  //     {
  //       path: 'bodyManage',
  //       name: 'bodyManage',
  //       component: () => import('@/views/institution/bodyManage'),
  //       meta: { title: '病例查询', icon: 'table' }
  //     }
  //     // {
  //     //   path: 'tree',
  //     //   name: 'Tree',
  //     //   component: () => import('@/views/tree/index'),
  //     //   meta: { title: '血液图像识别', icon: 'tree' }
  //     // }
  //   ]
  // },

  // {
  //   path: '/example',
  //   component: Layout,
  //   redirect: '/example/table',
  //   name: 'Example',
  //   meta: { title: 'Example', icon: 'el-icon-s-help' },
  //   children: [
  //     {
  //       path: 'table',
  //       name: 'Table',
  //       component: () => import('@/views/table/index'),
  //       meta: { title: 'Table', icon: 'table' }
  //     },
  //     {
  //       path: 'tree',
  //       name: 'Tree',
  //       component: () => import('@/views/tree/index'),
  //       meta: { title: 'Tree', icon: 'tree' }
  //     }
  //   ]
  // },

  // {
  //   path: '/form',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'index',
  //       name: 'Form',
  //       component: () => import('@/views/form/index'),
  //       meta: { title: 'Form', icon: 'form' }
  //     }
  //   ]
  // },

  // {
  //   path: '/nested',
  //   component: Layout,
  //   redirect: '/nested/menu1',
  //   name: 'Nested',
  //   meta: {
  //     title: 'Nested',
  //     icon: 'nested'
  //   },
  //   children: [
  //     {
  //       path: 'menu1',
  //       component: () => import('@/views/nested/menu1/index'), // Parent router-view
  //       name: 'Menu1',
  //       meta: { title: 'Menu1' },
  //       children: [
  //         {
  //           path: 'menu1-1',
  //           component: () => import('@/views/nested/menu1/menu1-1'),
  //           name: 'Menu1-1',
  //           meta: { title: 'Menu1-1' }
  //         },
  //         {
  //           path: 'menu1-2',
  //           component: () => import('@/views/nested/menu1/menu1-2'),
  //           name: 'Menu1-2',
  //           meta: { title: 'Menu1-2' },
  //           children: [
  //             {
  //               path: 'menu1-2-1',
  //               component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
  //               name: 'Menu1-2-1',
  //               meta: { title: 'Menu1-2-1' }
  //             },
  //             {
  //               path: 'menu1-2-2',
  //               component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
  //               name: 'Menu1-2-2',
  //               meta: { title: 'Menu1-2-2' }
  //             }
  //           ]
  //         },
  //         {
  //           path: 'menu1-3',
  //           component: () => import('@/views/nested/menu1/menu1-3'),
  //           name: 'Menu1-3',
  //           meta: { title: 'Menu1-3' }
  //         }
  //       ]
  //     },
  //     {
  //       path: 'menu2',
  //       component: () => import('@/views/nested/menu2/index'),
  //       name: 'Menu2',
  //       meta: { title: 'menu2' }
  //     }
  //   ]
  // },

  // {
  //   path: 'external-link',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
  //       meta: { title: 'External Link', icon: 'link' }
  //     }
  //   ]
  // },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
